home *** CD-ROM | disk | FTP | other *** search
- Path: news.primenet.com!ip068
- From: rogersr@primenet.com (Randy Rogers)
- Newsgroups: comp.lang.c++,comp.lang.c,comp.os.ms-windows.programmer.misc
- Subject: Re: fastest code
- Date: 16 Apr 1996 23:47:01 -0700
- Organization: Primenet
- Sender: root@primenet.com
- Message-ID: <4l2455$22f@nnrp1.news.primenet.com>
- References: <316112A2.7D37@public.sta.net.cn> <4kjpn0INN817@keats.ugrad.cs.ubc.ca> <829352535snz@genesis.demon.co.uk> <4kof6e$te@news1.mnsinc.com> <4krbhlINNbk4@keats.ugrad.cs.ubc.ca> <3171E8D2.41C67EA6@scn.de>
- X-Posted-By: ip068.phx.primenet.com
- X-Newsreader: News Xpress Version 1.0 Beta #4
-
- In article <3171E8D2.41C67EA6@scn.de>,
- Gerolf Wendland <wendland%hpp015%hpp001.mch2.scn.de@scn.de> wrote:
- >Kazimir Kylheku wrote:
- >It was addition instead of multiplication by constant values (i+i instead of
- 2*i)
- >
- >> If I were writing a compiler, I wouldn't bother ``optimizing'' this case at
- >> all: If the programmer thinks he knows better, let him have his addition!
- >
- >Let the programmer write down his way of solving the problem.
- >Let the compiler try to do the tideous optimization as much as possible.
-
-
- Why not just look at the machine code with the debugger?
- there is also an issue of whether signed arithemetic is being performed
- if not you could just shift left 1, add, or multiply with the same result
- how large are the vars...doubles would require additional register usage
-
- its my guess that any decent compiler is smart eough to optimize the
- multiplications to shifts and/or adds if possible to increase speed.
- if optimizations were selected to minimize memory usage the result may be
- different.
-
- randy
-